// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    {                                         \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    }
void err() { cerr << "\033[39;0m" << endl; }
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 1e5 + 50;

vector<int> dat[2][N];

int a[N][2], b[N][2];

int n;

int main(int argc, char const *argv[]) {
    // code
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i][0], &a[i][1]);
        dat[0][a[i][0]].push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &b[i][0], &b[i][1]);
        dat[1][b[i][0]].push_back(i);
    }

    for (int i = 0; i <= n; ++i) {
        sort(dat[0][i].begin(), dat[0][i].end(), [&](int x, int y) {
            return a[x][1] < a[y][1];
        });
        sort(dat[1][i].begin(), dat[1][i].end(), [&](int x, int y) {
            return b[x][1] < b[y][1];
        });
    }

    return 0;
}
